<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>修改人员档案</title>
		<link href="themes/css/ui.common.css" rel="stylesheet"
			type="text/css" />
		<link href="themes/css/ui.child.css" rel="stylesheet"
			type="text/css" />
		<link href="themes/css/ui.tips.css" rel="stylesheet"
			type="text/css" />
		<link href="style/jquery_ui/jquery-ui-1.8.custom.css"
			rel="stylesheet" type="text/css" />
		<link id="skin_css" rel="stylesheet" type="text/css"
			href="themes/css/ui.c.blue.css" />
		<link href="style/mailSender.css" rel="stylesheet"
			type="text/css" />
			<link rel="stylesheet" href="themes/css/ui.validation.css" type="text/css"></link>
		<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
		<script src="Scripts/jquery.json-2.2.min.js"
			type="text/javascript"></script>
		<script src="Scripts/jquery-ui-1.8.custom.min.js"
			type="text/javascript"></script>
		<script src="Scripts/ui.default.js " type="text/javascript"
			charset="UTF-8"></script>
		<script src="Scripts/ui.admincp.js" type="text/javascript"
			charset="UTF-8"></script>
		<script src="HtmlEditor/kindeditor.js" type="text/javascript"></script>
		<script src="Scripts/HtmEditorCreator.js" type="text/javascript"></script> 
		<script type="text/javascript" src="Scripts/jquery.jSelectDate.js"></script>
		   <script src="Scripts/ui.clientDateHelper.js" type="text/javascript"></script>
		   	<script type="text/javascript" src="Scripts/ui.validation.js"></script>
		<style type="text/css">
	.text-align-right {
		text-align: right;
		padding-right: 2px;
		font-weight: bolder;
	}

	.text-control-left {
		text-align: left;
		width: 200px;
	}

	.control-width-180 {
		width: 180px;
	}

	.control-width-80 {
		width: 80px;
	}

	.input-control {
		border: 0;
		height: 24px;
		padding: 2px;
	}

	.td-width-100 {
		text-align: left;
		width: 100px;
	}

	.td-width-100 {
		width: 120px;
	}

	.style1 {
	
	}

	.input-big-text {
		width: 635px;
		height: 100px;
	}

	td {
		padding: 2px;
	}
	</style>
	
	<SCRIPT type="text/javascript">
	$(function () {
           switcher();
           if( $.trim($("#staffId").val()) != '' && $.trim($("#archiveId").val()) != ''){
           		$("#addRPInfoButton").attr("disabled",false);
           		$("#btnSubmit").attr("disabled",false);
           		$("#addPhotoButton").attr("disabled",false);
		   }
             var years = generateYeasFrom(2003,new Date().getFullYear(),"DESC");
            $("#selYear1").html(years);
            var months = generateMonths();
            $("#selMonth1").html(months).change(function () {
              
                var monthSelector = "#selMonth1";
                var yearSelector = "#selYear1";
                var daySelector = "#selDay1";
                var month = $(monthSelector).val();
                var year =$(yearSelector).val();

                if (year == -1) {
                    return;
                }

                if (month == -1) {
                    $(daySelector).html("");
                } else {
                    var days = generateDays(year, month);
                    $(daySelector).html(days);
                }
            }).val("1");
            var now = new Date();
			 
			$("#selYear1").val(now.getFullYear());
			$("#selMonth1 option:selected").val(jSelectDate.returnMonth( now.getMonth())).change();
			$("#selDay1").val(now.getDate());
			
			
			setValidate();
    });
    
    function setValidate(){
    
    	 $("#form").validatingForm({
        	submitButtonId:"#btnSubmit",
        	  clearErrorsOnFocus:true,
        	 
        	 validateOnBlur:true,
        	success:submit 
        });
    }
    
	function switcher() {
	$("#sectionSelector").change( function() {
		var sectionId = $(this).val();
		$.post("archivesInfo!queryStaffBySection.action", {
			"sectionId" :sectionId
		}, function(data) {
			if(data != '')
			//对应的物资信息添加到select中
			$("#staffSelector").html("").append(data);
			else
			$("#staffSelector").html("").append("<option value=\"\">-请先选择部门-</option>" );
			});
		},

		"html");
		
		$("#drl_isRP").change( function() {
		var isRP = $(this).val();
		$.post("archivesInfo!queryRPInfoByIsRP.action", {
			"isRP" :isRP
		}, function(data) {
			if(data != '')
			//对应的物资信息添加到select中
			$("#drl_rpInfoCategory").html("").append(data);
			else
			$("#drl_rpInfoCategory").html("").append("<option value=\"\">-请先选择类别分类-</option>" );
			});
		},

		"html");
		
		$("#txt_staffNo").change( function() {
		var staffNo = $(this).val();
		$.post("archivesInfo!verifyStaffNo.action", {
			"staffNo" :staffNo
		}, function(data) {
			if(data == '1' && staffNo != data){
				alert("注意:该学号已存在!");
				$("#txt_staffNo").focus();
			}
		});
		},
		"text");
		
		$("#txt_archiveNo").change( function() {
		var archiveNo = $(this).val();
		$.post("archivesInfo!verifyArchiveNo.action", {
			"archiveNo" :archiveNo
		}, function(data) {
			if(data == '1' && archiveNo != data){
				alert("注意:该档案编号已存在!");
				$("#txt_archiveNo").focus();
			}
		});
		},
		"text");
	}
	
	function clearPostSelector(){
		$("#staffSelector").html("").append("<option value=\"\">-请先选择部门-</option>" );
	}
	
	function changeStaffSelector(){
		var staffId = $('#staffSelector').val();
		location = "archivesInfo!modifyByManager.action?staffId="+staffId;
	}
	</SCRIPT>
	<SCRIPT type="text/javascript">
			$(function(){
				$("#dialog").dialog("destroy"); 
				$("#dialog-form").dialog({
				autoOpen: false,
				height: 250,
				width: 500,
				modal: true,
				 
				close: function() {
					//allFields.val('').removeClass('ui-state-error');
				}
				});
				
				$('#addRPInfoButton').click(function() {   
					$("#dialog-form").dialog({'title':"添加奖励或惩罚信息"});
					clearInputControlValue("#dialog-form");
					var now = new Date(); 
					  $("#selYear1").val(now.getFullYear());
					  $("#selMonth1").val(jSelectDate.returnMonth( now.getMonth()));
					 $("#selDay1").val(now.getDate()); 
				     $('#dialog-form').dialog('open'); 
				}); 
				
			});
			
			function submit(){
					var staffId = $.trim($("#staffId").val());
					
					 
					 if( $("#selYear1").val()=="-1" ||
					 $("#selMonth1").val()=="-1" ||$("#selDay1").val() =="-1" )
					 {
					 	alert("请选择正确的时间.");
					 return false;
					 }
					  var date = $("#selYear1").val()+"-"+$("#selMonth1").val()+"-"+$("#selDay1").val();
					var rpInfo = {
					"staffId": $.trim($("#staffId").val()),
					"archiveId": $.trim($("#archiveId").val()),
					"rpInfoCategory": $.trim($("#drl_rpInfoCategory").val()),
					"createTime":  date,
					"contents":$.trim($("#txt_contents").val())
					} ;
				
					var jsonString = $.toJSON(rpInfo);
 
					$.post(
					"archivesInfo!addRPInfo.action",
					{
						rpInfoJsonString: jsonString
					},
					function(data){
						location = "archivesInfo!modifyByManager.action?staffId="+staffId;
					},
					"json"
					);
				}
	</SCRIPT>
	</head>
	<body>
		<div class="PageChild_Title">
			<img src="themes/images/default/icons/archives.png" class="PageChild_Tbtnpic" />
			<span class="PageChild_separate"></span>
			<span class="PageChild_TbtnText"><h2>修改人员档案</h2></span>
			<span class="PageChild_separate"></span>
			<div id="marker" class="red-tips">
			</div>
			<div class="clear">
			</div>
		</div>
		&nbsp;
		<div align="center">
		<table>
		<tr>
			<td class="text-align-right" style="width: 40px;">部门:</td>
			<td><s:select list="sectionList" listKey="sectionId" listValue="sectionName" headerKey="" headerValue="-请选择-" id="sectionSelector" name="sectionId" theme="simple" cssClass="control-width-40 clearable" cssStyle="width: 152px; height: 26px" value="sectionId"></s:select></td>
			<td class="text-align-right" style="width: 40px;">人员:</td>
			<td><s:select list="#{'':'-请先选择部门-'}" name="staffId" id="staffSelector" theme="simple" cssClass="control-width-40 clearable input-control" cssStyle="width: 152px; height: 26px" onchange="changeStaffSelector();"></s:select></td>
		</tr>
		</table>
		</div>
		<br/>
		<table id="form" style="border: 1px solid gray; padding: 1px;" border="0"
			cellpadding="0" cellspacing="0" align="center">
			<tr><td colspan="2">&nbsp;</td></tr>
			<tr>
				<td>
			<form action="archivesInfo!modifyInfoByManager.action" method="post">
			<table border="0"
			cellpadding="0" cellspacing="0" align="center">
			<tr>
				<td colspan="4" align="center">
					<input type="hidden" id="staffId" name="staffId" value="${staffId }"/>
					<input type="hidden" id="archiveId" name="archiveId" value="${archiveId }"/>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;学号:
				</td>
				<td style="width: 100px" valign="middle" class="style1">
					<input id="txt_staffNo" name="staffNo" class="control-width-100  required-field  input-control clearable" value="${staffNo}">
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;密码:
				</td>
				<td style="width: 200px" valign="middle" class="style1">
					<input id="pwd" name="staffPwd" class="control-width-100 input-control  required-field  clearable" value="${staffPwd}" disabled="disabled">
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;姓名:
				</td>
				<td style="width: 100px" valign="middle" class="style1">
					<input id="staffName" name="staffName" class="control-width-100 required-field input-control clearable" value="${staffName}">
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;性别:
				</td>
				<td style="width: 100px" class="style1">
					<input id="gender" name="gender" class="control-width-100 input-control clearable" value="${gender}" disabled="disabled">
				</td>
			</tr>
			<tr>
				<td class="text-align-right">
					&nbsp;年龄:
				</td>
				<td class="style1">
					<input id="age" name="age" max="60" min="16" class="control-width-100 betweenvalue-field required-field input-control clearable" value="${age}">
				</td>
				<td class="text-align-right">
					&nbsp;生日:
				</td>
				<td class="style1">
					<input id="birthday" name="birthday" class="control-width-100 required-field input-control NeedDate" value="${birthday}">
				</td>
			</tr>
			<tr>
				<td class="text-align-right">
					&nbsp;政治面貌:
				</td>
				<td class="style1">
					<s:select list="#{'团员':'团员','预备党员':'预备党员','党员':'党员','群众':'群众'}" name="politician" theme="simple" cssClass="control-width-40 clearable" cssStyle="width: 152px; height: 26px"></s:select>
				</td>
				<td class="text-align-right">
					&nbsp;年级:
				</td>
				<td class="style1">
					 <input id="grade" name="grade" class="control-width-100 required-field input-control clearable" value="${grade}">
				</td>
			</tr>
			<tr>
				<td class="text-align-right">
					&nbsp;专业:
				</td>
				<td class="style1">
					<s:select id="marjorList" list="majorList" listKey="majorId" listValue="majorName" headerKey="-1" headerValue="-请选择-" name="majorId" theme="simple" emptyValueMsg="请选择专业。" emptyValueForValidate="-1" cssClass="selectable-field control-width-40 clearable" cssStyle="width: 152px; height: 26px"></s:select>
				</td>
				<td class="text-align-right">
					&nbsp;班级:
				</td>
				<td class="style1">
					<input name="classNo" id="classNo" class="control-width-100 input-control required-field clearable" value="${classNo}">
				</td>
			</tr>
			<tr>
				<td class="text-align-right">
					&nbsp;联系电话:
				</td>
				<td class="style1">
					<input name="telphone" id="telphone" class="control-width-100 input-control telphone-field clearable" value="${telphone}">
				</td>
				<td class="text-align-right">
					&nbsp;人员邮箱:
				</td>
				<td class="style1">
					<input name="mail" id="email" class="control-width-100 input-control email-field clearable" value="${mail}" disabled="disabled">
				</td>

			</tr>
			<tr>
				<td class="text-align-right">
					&nbsp;寝室地址:
				</td>
				<td class="style1">
					<input name="dormitory" id="dormitory" class="control-width-100 input-control  required-field  clearable" value="${dormitory}">
				</td>
				<td class="text-align-right">
					&nbsp;档案编号:
				</td>
				<td class="style1">
					<input id="txt_archiveNo" name="archiveNo" class="control-width-100 required-field input-control clearable" value="${archiveNo}">
				</td>
			</tr>
			<tr>
				<td class="text-align-right">
					&nbsp;所在部门:
				</td>
				<td class="style1">
					<input name="" id="depart" class="control-width-100 input-control clearable" value="${sectionName}" disabled="disabled">
				</td>
				<td class="text-align-right">
					&nbsp;所在职位:
				</td>
				<td class="style1">
                	<input name="postId" id="postId" class="control-width-100 input-control clearable" value="${postName}" disabled="disabled">
				</td>
			</tr>
			<tr>
				<td colspan="4" align="center">
					&nbsp;
				</td>
			</tr>
			<tr>
				<td colspan="4" align="center">
					<input id="btnSubmit" type="submit" class="ui-button" value="提交" disabled="disabled"/>
				</td>
			</tr>
			<tr>
				<td colspan="4" align="center">
					&nbsp;
				</td>
			</tr>
		</table>
		</form>
				</td>
				<td>
					<table width="300">
						<tr>
							<td style="width: 200px;" align="center">
								<div style="border: 1px solid gray; padding: 5px; width: 160px;">
									<img src="getPhoto.action?avatarId=${avatarId}&gender=${gender}" width="140" height="180"/>
								</div>
							</td>
						</tr>
						<s:form action ="archivesInfo!addPhoto.action" method ="post" enctype ="multipart/form-data" > 
						<tr>
							<td align="center">
								<s:hidden name="avatarId"></s:hidden>
								<s:hidden name="staffId"></s:hidden>
							</td>
						</tr>
						<tr>
							<td align="center">
								<s:file name ="staffPhoto" label ="照片" cssClass="control-width-100 input-control"/>
							</td>
						</tr>
						<tr>
							<td>
								<s:submit value="上传" id="addPhotoButton" cssClass="ui-button clearable" align="center" disabled="true"></s:submit>
							</td>
						</tr>
						</s:form>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<table width="100%">
						<tr>
							<td class="text-align-right" valign="top" width="60">
								奖励:
							</td>
							<td class="style1" valign="top" align="left" colspan="4">
								<div class="PageChild_List">
									<table width="100%" border="0" cellspacing="0"
										style="text-align: left">
										<tbody class="PageChild_List_head">
											<tr>
												<td width="120">
													时间
												</td>
												<td>
													奖励内容
												</td>
												<td width="100">
													奖励类别
												</td>
												<td class="td_width40">
													删除
												</td>
											</tr>
										</tbody>
										<tbody class="PageChild_List_main" style="text-align: left">
										<s:if test="rewardList != null && rewardList.size != 0">
											<s:iterator value="rewardList" var="item">
												<tr class='td_no_bord'>
													<td>
														<span>${item.strCreateTime}</span>&nbsp;
													</td>
													<td>
														<span>${item.contents}</span>&nbsp;
													</td>
													<td>
														<span>${item.rpCategory.categoryName}</span>&nbsp;
													</td>
													<td>
														<a href="javascript:;"
															onclick='location="archivesInfo!deleteRPInfo.action?rpId=${item.rpId}&staffId=${staffId}";'><img
																src="themes/icons/delete.png" /> </a>
													</td>
												</tr>
											</s:iterator>
										</s:if>
										<s:else><tr><td colspan="4"><span>无记录</span></td></tr></s:else>
										</tbody>
									</table>
								</div>
							</td>
						</tr>
						<tr>
							<td class="text-align-right" valign="top">
								惩罚:
							</td>
							<td class="style1" valign="top" align="left" colspan="4">
								<div class="PageChild_List">
									<table width="100%" border="0" cellspacing="0"
										style="text-align: left">
										<tbody class="PageChild_List_head">
											<tr>
												<td width="120">
													时间
												</td>
												<td>
													惩罚内容
												</td>
												<td width="100">
													惩罚类别
												</td>
												<td class="td_width40">
													删除
												</td>
											</tr>
										</tbody>
										<tbody class="PageChild_List_main" style="text-align: left">
										<s:if test="punishList != null && punishList.size != 0">
											<s:iterator value="punishList" var="item">
												<tr class='td_no_bord'>
													<td>
														<span>${item.strCreateTime}</span>&nbsp;
													</td>
													<td>
														<span>${item.contents}</span>&nbsp;
													</td>
													<td>
														<span>${item.rpCategory.categoryName}</span>&nbsp;
													</td>
													<td>
														<a href="javascript:;"
															onclick='location="archivesInfo!deleteRPInfo.action?rpId=${item.rpId}&staffId=${staffId}";'><img
																src="themes/icons/delete.png" /> </a>
													</td>
												</tr>
											</s:iterator>
											</s:if>
											<s:else><tr><td colspan="4"><span>无记录</span></td></tr></s:else>
										</tbody>
									</table>
									<input type="button" class="ui-button" id="addRPInfoButton" value="添加" disabled="disabled" />
								</div>
							</td>
						</tr>
						<tr>
							<td class="text-align-right" valign="top">
								操作记录:
							</td>
							<td class="style1" valign="top" align="left" colspan="4">
								<div class="PageChild_List">
									<table width="100%" border="0" cellspacing="0"
										style="text-align: left">
										<tbody class="PageChild_List_head">
											<tr>
												<td width="120">
													时间
												</td>
												<td>
													操作内容
												</td>
												<td width="100">
													操作类别
												</td>
												<td class="td_width40">
													删除
												</td>
											</tr>
										</tbody>
										<tbody class="PageChild_List_main" style="text-align: left">
										<s:if test="recordList != null && recordList.size != 0">
											<s:iterator value="recordList" var="item">
												<tr class='td_no_bord'>

													<td>
														<span>${item.strCreateTime}</span>&nbsp;
													</td>
													<td>
														<span>${item.messages}</span>&nbsp;
													</td>
													<td>
														<span>${item.recordCategory.categoryName}</span>&nbsp;
													</td>

													<td>
														<a href="javascript:;"
															onclick='location="archivesInfo!deleteRecordInfo.action?recordId=${item.recordId}&staffId=${staffId}";'><img
																src="themes/icons/delete.png" /> </a>
													</td>
												</tr>
											</s:iterator>
											</s:if>
											<s:else><tr><td colspan="4"><span>无记录</span></td></tr></s:else>
										</tbody>
									</table>
								</div>
							</td>
						</tr>
						<tr>
							<td colspan="4" align="center">
								&nbsp;
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</body>
	
	<!-- 弹出层标签 -->
	<div id="dialog-form" style="display: none;" title="添加奖励或惩罚信息">
		<div class="ui-mainTab">
			<div><input type="text" id="sectionId" class="hiddenObject clearable" />
				<table width="100%" class="tb tb2">
					<tr>
						<td class="mtd">
							&nbsp;信息类别分类:
						</td>
						<td>
							<s:select list="#{'1':'奖励','0':'惩罚'}" id="drl_isRP" headerKey="" headerValue="-请选择-" theme="simple"
								cssClass="control clearable"></s:select>
						</td>
					</tr>
					<tr>
						<td class="mtd">
							&nbsp;信息类别:
						</td>
						<td>
							<s:select list="#{'':'-请选择-'}" id="drl_rpInfoCategory" theme="simple" cssClass="control clearable"></s:select>
						</td>
					</tr>
					<tr>
						<td class="mtd">
							时间:
						</td>
						<td>
							 <select id="selYear1">
                       		 </select>
                       			 年 
	                        <select id="selMonth1" selectortype="start">
	                        </select>月
	                        <select id="selDay1"  >
	                        </select>日
						 </td>
					</tr>
					<tr>
						<td class="mtd">
							内容:
						</td>
						<td>
							<input class="control clearable" type="text" id="txt_contents">
						</td>
					</tr>
					<tr>
						<td>
							&nbsp;
						</td>
						<td>
							<div>
								<input type="button" value="提 交" class="o-btn SubmitButton" onclick="submit();">
								&nbsp;
								<input type="button" name="name" id="cancelAddGoodsInfoButton"
									class="dialogFormCloseButton o-btn" dialogForm="#dialog-form"
									value="关闭" />
							</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
		<!-- 弹出层结束 -->
</html>
